﻿using System;
using System.Threading;

namespace XGame
{
    public class Init
    {
        public void Start()
        {
            try
            {
                AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
                {
                    Log.Error(e.ExceptionObject.ToString());
                };
                
                World.Instance.AddSingleton<TimeInfo>();
                World.Instance.AddSingleton<FiberManager>();

                //World.Instance.AddSingleton<CodeLoader>();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }

        public void Update()
        {
            TimeInfo.Instance.Update();
            FiberManager.Instance.Update();
        }

        public void LateUpdate()
        {
            FiberManager.Instance.LateUpdate();
        }
    }
}